<template>
  <el-dialog
    :visible.sync="$attrs.visable"
    width="500px"
    :before-close="handleClose"
    append-to-body
    class="dialog_nopadd"
  >
    <template slot="title">
      <span class="f-15">转让群主</span>
      <span class="f-12 c_999">仅可转让给同企业具有客户群使用权限的成员</span>
    </template>
    <div class="h_box">
      <div class="boxheader flexbetween">
        <span class="c_text2 fw-6 ml-12">群成员</span>
        <el-input
          placeholder="搜索群成员"
          v-model="queryParams.keyword"
          size="small"
          style="width: 164px"
          @keyup.enter.native="handleQuery"
          suffix-icon="el-icon-search"
        >
        </el-input>
      </div>
      <div class="boxbody p-0">
        <div
          class="groupitem flex aligncenter"
          v-for="(item, index) in grouplist"
          :key="index"
        >
          <div class="flex groupleft">
            <div class="checkbox flexcenter" @click="handlecheck(item, index)">
              <svg-icon
                v-show="!item.checked"
                icon-class="iradio"
                class-name="checkicon c_999"
              />
              <svg-icon
                v-show="item.checked"
                icon-class="iradio_s"
                class-name="checkicon c_primary"
              />
            </div>
            <div class="accoutitem commhover flex mb-3">
              <img
                src="https://wework.qpic.cn/wwpic/576270_jL0ikDqEQ1SA2FC_1697685555/0"
                alt=""
                class="avatar mr-12"
              />
              <div class="itemcontent">
                <div class="c_text2 f-14 textover">测试群</div>
                <div class="c_f90 f-12 textover">@志新</div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button size="small" @click="handleClose">取 消</el-button>
      <el-button size="small" type="danger" @click="handleSubmit">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      queryParams: {
        keyword: "",
      },
      grouplist: [
        { id: 1, name: "测试群", checked: false },
        { id: 2, name: "测试群", checked: true },
      ],
    };
  },
  props: {},
  created() {},
  methods: {
    handleClose() {
      this.$emit("close"); //关闭弹窗;
    },

    handleQuery() {},

    handlecheck(item) {
      console.log("item");
      this.grouplist.forEach((i) => {
        if (i.id == item.id) {
          i.checked = true;
        } else {
          i.checked = false;
        }
      });
      console.log("this.grouplist:", this.grouplist);
    },
  },
};
</script>
<style lang="scss" scoped>
.h_box {
  height: 580px;
}
.boxheader {
  padding: 0 12px;
  height: 42px;
  background: #fafafa;
  border-bottom: 1px solid #e9e9e9;
  position: sticky;
  top: 0;
  z-index: 11;
}
.groupitem {
  width: 100%;
  padding: 3px;
  &.active {
    background-color: #ebf2ff;
  }
  &:hover {
    background-color: #f0f0f0;
  }

  .groupleft {
    width: calc(100% - 50px);
  }
  .checkbox {
    width: 60px;
    .checkicon {
      height: 16px;
      width: 16px;
    }
  }
  .labelbox {
    background: #f1f1f4;
    border-radius: 2px;
    border: 1px solid #c1c1f1;
    color: #4b5a95;
    line-height: 20px;
    padding: 2px 8px;
  }
  .g_name {
    width: 90%;
  }
}
.accoutitem {
  padding: 6px 12px;
  &.active {
    background-color: #ebf2ff;
  }
  &:hover {
    background-color: #f0f0f0;
  }
  .avatar {
    width: 40px;
    height: 40px;
    border-radius: 4px;
  }
  .itemcontent {
    width: calc(100% - 52px);
  }
}
</style>